package com.supertool.monitor;
import org.apache.commons.lang.StringUtils;

/**
 * Created by supertool on 2014/11/5.
 */

public class LogParser extends com.supertool.tong.merger.util.LogParser{
    private static char SEP = '^';
    private static char KVSEP = '=';
    private static String UUID = "uuid";
    private static String CAID = "k";
    private static String TIME = "ti";
    private static String TYPE = "tp";
    private static String MINID = "ae";
    private static String IP = "ip";
    private static final String EMPTYSTRING = "";
    public LogParser(){
        System.out.println("%%%%%%%%%%%%%%%%%%%%%KeyParser%%%%%%%%%%");
    }
    public Comparable parse(String log){
        return new LogKey("a","a","a",0,true,"a");

        /*
		LogKey logKey = null;
		try{
			String[] strs = StringUtils.split(log, SEP);
			String uuid = EMPTYSTRING;
			String caid = EMPTYSTRING;
			String minid = EMPTYSTRING;
			String type = EMPTYSTRING;
			int time = 0;
            String ip = EMPTYSTRING;
			for(String str : strs){
				int index = str.indexOf(KVSEP);
				if(index>0){
					String k = str.substring(0, index);
					if(k.equals(UUID))
						uuid = str.substring(index+1);
					else if(k.equals(CAID))
						caid = str.substring(index+1);
					else if(k.equals(MINID))
						minid = str.substring(index+1);
					else if(k.equals(TYPE))
						type = str.substring(index+1);
					else if(k.equals(TIME))
						time = Integer.parseInt(str.substring(index+1).trim());
                    else if(k.equals(IP))
                        ip = str.substring(index+1);

				}
			}
			boolean isMinisite=type.equals("evn");
			logKey = new LogKey(uuid, caid, minid, time, isMinisite,ip);
		}catch(Exception ex) {
			//ex.printStackTrace();
			System.err.println("bad line:" +ex+",   "+log);
		}
		return logKey;
		*/
    }

    public static void main(String[] args) {
        String value = "b=003_21^c=http://localhost/indx.htm^d=^f=10^h=1024*768^j=zh^p=2w-a0^k=389^a=TIsM1+-+Bm+^s=222.83.126.128 192.168.1.1^time=123";
        value= "type=impression^k=1753^a=EFyIU0Utb1i0^time=1363971168^p=B8o0^ip=122.194.188.4";
        new LogParser().parse(value);
    }
}
